mod segment01;
mod segment02;
mod segment03;
mod segment04;
mod segment05;

fn double_first(vec: Vec<&str>) -> i32 {
    let first = vec.first().unwrap(); // 生成错误 1
    2 * first.parse::<i32>().unwrap() // 生成错误 2
}

pub fn practice() {
    let numbers = vec!["42", "93", "18"];
    println!("The first doubled is {}", double_first(numbers));

    // let empty = vec![];
    // println!("The first doubled is {}", double_first(empty));
    // 错误1：输入 vector 为空

    // let strings = vec!["tofu", "93", "18"];
    // println!("The first doubled is {}", double_first(strings));
    // 错误2：此元素不能解析成数字

    println!("");
    segment01::practice();

    println!("");
    segment02::practice();

    println!("");
    segment03::practice();

    println!("");
    segment04::practice();

    println!("");
    segment05::practice();
}
